package LuoGu.排序.拼数;

import java.util.Scanner;

//类似于冒泡排序
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String [] temp = new String[n];
        for(int i=0;i<n;i++){
            temp[i] = s.next();
        }
        for(int i=n-1;i>=1;i--){
            for(int j=0;j<i;j++){
                if(Long.valueOf(temp[j]+temp[j+1])<Long.valueOf(temp[j+1]+temp[j])){
                    String tempp = temp[j];
                    temp[j] = temp[j+1];
                    temp[j+1] = tempp;
                }
            }
        }
        for(String i:temp) System.out.print(i);
    }
}
